============================================== FlCalc - A Programmer's Hexadecimal Calculator David Rushall (C) 1997 ============================================== WHAT IS FLCALC? FlCalc is a programmers calculator for Psion Series 3a/c machines. Features include: Calc-style expression parser, complete with support for nested parenthesis. 8-slot expression history. 6 Arithmetic operators, including integer modulus. 7 Bit-wise operators, including logic, shifts and mirror-image. 3 Multi-format result settings: Hexadecimal and binary. Hexadecimal, decimal, ASCII and EBCDIC. All of the above. 2 Default input formats: decimal or hexadecimal. 2 Extra input formats: binary and octal. Choice of operator names: symbolic or textual. 10 Memories, shared with Calc application for easy transfer. 32-bit integer arithmetic. It was written primarily for personal use, so please excuse its quirks and these brief instructions. CONDITIONS OF USE FlCalc is Freeware. It is _not_ public domain and copyright remains with the author. Permission is given to use FlCalc free of charge, provided the user accepts the following conditions: FlCalc shall only be distributed with this text file, and neither the application nor this file may be changed. Use of FlCalc is at the user's own risk. The author shall not be responsible for any loss or damaged caused through the use of this application. FlCalc is supplied 'as-is'. The author is not required to correct any errors it may contain. INSTALLATION To install FlCalc, simply copy the following files to your Series 3a/c (either the internal drive or an SSD)... \APP\FlCalc.opa - main program \APP\FLUTILS\Flutils.fl0 - shared application library (see below) Install the FlCalc application on to the System screen, in the normal way, and just select the new icon to start the application. NOTE: If you wish to use my FlUtils suite and FlCalc on the same machine, make sure you use the version Flutils.fl0 supplied in THIS archive (or a newer one if you have one, see below). DO NOT attempt to run FlCalc with the older version of the Flutils.fl0 library, or it will not start. ADVANCED NOTE: If you have another of my applications (such as Solun) you will already have a copy of Flutils.fl0 on your machine. These applications can share a single copy of Flutils.fl0, provided you: Determine which is the latest level of FlUtils you have (either run the Flutils.fl0 module directly with RunOpl, or view start of the module in an editor and look for the version number) Install the latest highest version as \OPO\Flutils.fl0 BASIC OPERATION The FlCalc display is split into two areas: a 9 line result display and an input window, below. In addition to the calculation being editted, the latter contains the current time and the following status indicators: Menu/Edit mode (see below) Value of current memory (in hexadecimal) Default input number format (hexadecimal or decimal) Output format (see below) As you use FlCalc, it switches between two modes, which are indicated by the Menu/Edit indicator. In Menu mode, the , and -key combinations have their normal meanings. However, the following keys have special meanings: re-edit last calculation. re-evaluate last calculation (equivalent to , useful for iterative calculations, see below). When you start to enter a calculation, FlCalc enters Edit mode. Once in Edit mode, you must either enter your calculation (see below), followed by the key, or enter a special command: To return to Menu mode enter an empty line (i.e. press followed by ) To choose a menu item directly, enter the menu item's letter followed by the " character, or key (e.g. to see the values of all memories, press letter) SIMPLE CALCULATIONS Using FlCalc for simple calculations is fairly simple, but it should be remembered that FlCalc works solely in 32-bit integers; the results of divisions get rounded down and there is no concept of floating-point. By default numbers entered into an expression are interpretted as either decimal or hexadecimal, as indicated by the input format indicator in the edit window. Use the Preferences menu option (-Q) to change this default. However, whatever the input format setting, it is possible to override this for a specific number with the following prefixes: d. - decimal (e.g. d.999) b. - binary number (e.g. b.11111111) o. - octal number (e.g. o.777) x. - hexdecimal (e.g. x.ffff, but the standard C language prefix for hexadecimal (0x) is also supported) Of course, a calculator with just numbers is of little use - we need operators too. FlCalc supports the standard arithmetic operators, so... d.10+x.f3-b.11 ...does what you might expect. Operator precedence is also implemented, with parenthesis being used to override in the normal way, so... 10+2*3 ...evaluates to 16 (assuming decimal format), whilst... (10+2)*3 ...gives 36. In addition to arithmetic operators, FlCalc implements a selection of bit-wise operators, such as the bit-wise and operator, &. For example... b.1100 & b.0101 ...gives b.0100. Finally, there are some unary operators, such as the integer minus (-) and bit-wise not (~). To aid in remembering little-used operators, all have both a long name and symbolic name, which can be used interchangably. Long names begin with the : character. For example, the following expression is valid... 10 :add 43 :and 4 The following is a list of all operators, with both long and symbolic names. Arithmetic: - :neg (unary, e.g. -9) * :mul / :div (integer division) % :mod (integer modulus) + :add - :sub Bit-wise logical: ~ :not (unary) & :and | ? :or (since | is awkward on the Series 3a keyboard FlCalc supports ? instead) ^ :xor (exclusive or) Bit-wise shifts: # :mirror (unary, reflects bits within 32-bit word) << :left (e.g. b.0010<<2 gives b.1000) >> :right The preferences of the binary operators are as follows, in decreasing order: * / % + - << >> & ^ | MEMORIES AND ITERATIVE CALCULATIONS In addition to the basic operators described above, FlCalc has a few advanced features. The first of these is the special variable, :ans, which contains the result of the last calcualtion. For convience, :ans can also be written as . (i.e. a full-stop). For example... . + 5 ...gives the last result plus 5. The ten Calc memories are also available for use by FlCalc, and named m0...m9. Sharing the memories in this way allows easy transfer of results between Calc and FlCalc, but remember that FlCalc deals with 32-bit integers. The display memories menu option (-D) lists the values of all ten memories, both in hexadecimal and decimal. (Note: if any Calc memory is out of FlCalc's 32-bit range, the value will be displayed as *s) Memories can be used in any calculation by simply using their name, e.g... 10 + m0 To set memories, use the special assignment operator, =, e.g... m0 = (343 * 12) The value of the assignment operator expression is the final value of the memory. For example, the value of... 10 + (m0=4) ...is 14, with m0 being set to the value of 4 as a side-effect. Finally, FlCalc has another trick up its sleve: the ; construct, which gives the value of its second argument, after evaluating its first. For example, the value of... 4 ; 6 ...is 6. At first, this might seem a little pointless, but it allows you to write things like this... m0=5 ; m0+3 ...which gives the result 8. The left-hand expression is evaluated, resulting in side-effect of assigning m0 to 5, but the result is discarded. The right-hand expression is the evaluated. Note that the ; symbol must appear at the top-level of the entire calculation, so... m1=(m0=4; 3) ...is invalid. However, you can specify a sequence of many expressions, so expressions such as the following are fine... m1=3 ; m2=5*m1 ; m1+m2 One of the advantages of all this is that simple iterative calculations can be set up, taking advantage of the reevaluate key, . By way of a simple example, entering... 0 ...to set the :ans variable to zero, and then entering... . + 1 ...gives 1. However, pressing to iteratively reevaluate gives 2, and then 3, and so on. By combining this with the memories, the ; construct and the expression history (available from the menu), FlCalc can be used to step through mini programs. OUTPUT FORMATS FlCalc features a multi-format result display; the results of each calculation are displayed in both hexadecimal and at least one other format, for convenience. Use the Preferences dialog (-Q) to choose between: Hexadecimal and binary Hexadecimal, decimal, 4 characters of ASCII and 4 characters of EBCDIC All the above formats, displayed in two lines. CHARACTER TABLES If you have Ascii2 (from my FlUtils suite) installed (as \APP\FLUTILS\Ascii2.fl1) then the table of ASCII and EBCDIC characters is available directly from the FlCalc menu. GETTING IN TOUCH If you have any comments regarding FlCalc, then please contact me at the following address: dave@piecafe.demon.co.uk If you have access to the WWW then visit the following URL for the latest details of FlCalc and other software for Psion machines: http://www.piecafe.demon.co.uk/ ----- I hope this software is useful. Dave Rushall, 1997